from django.utils.deprecation import MiddlewareMixin
from django.http import JsonResponse
import json


# 检查权限添加
class CheckPremission(MiddlewareMixin):

    def process_request(self,request):

        # 一般添加的是post
        if request.path in ['/app01/user/','/app01/deparment/'] and request.method == 'POST':
            print('1')
            dict = json.loads(request.body.decode())
            auth = str(dict.get("auth"))
            print('auth',auth)
            if auth == "0":
                return JsonResponse({"code":2000,"msg":"权限不够"})
        else:
            print('2')




        pass